import { defineStore } from "pinia";
import { AuthState } from "@/stores/interface/index";

// import { useUserStore } from "@/stores/modules/user";
export const useAuthStore = defineStore({
  id: "auth",
  state: (): AuthState => ({
    // 按钮权限列表
    authButtonList: [],
    // 菜单权限列表
    authMenuList: [],
    // 用户角色
    roles: [],
    // 刷新页面后是否在获取权限
    getAuth: 0
  }),
  actions: {
    setGetAuth(value) {
      this.getAuth = value;
    },
    // 获取用户权限
    async getAuthBySysUser({ buttonList, menuList, roleList }) {
      // 过滤出可显示的路由
      this.authMenuList = menuList || [];
      // 获取用户角色
      this.roles = roleList || [];
      // 获取用户按钮权限
      this.authButtonList = buttonList || [];
    }
  }
});
